#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <queue>
#include <thread>
#include <unordered_map>
#include <vector>

class ThreadPool {
 public:
  using Task = std::function<void()>;
  // 构造函数
  ThreadPool();
  ThreadPool(int thread_num);
  // 析构函数
  ~ThreadPool();
  // 启动线程池

  // 添加任务
  void AddTask(Task&& f);
  // 线程运行函数
  void ThreadFunc();

 private:
  int thread_num_;
  std::vector<std::thread> thread_vec_;
  std::queue<Task> task_que_;

  std::mutex mtx_;
  std::condition_variable full_cond_;
  std::condition_variable empty_cond_;

  std::atomic<bool> stop_;
};